subroutine init_object_type(lunit)
  use global_param,only:n_point_type
  use data_param,only:n_label_data
  use label_data_param,only:n_obj_type
  use label_data_param,only:obj_type
  use motion_param,only:n_motion
  use motion_param,only:default_motion
  use motion_param,only:mtype
  implicit none

  interface
     function str2config(str)
       integer,pointer,dimension(:) :: str2config
       character :: str*(*)
     end function str2config

     function alloc_groups(glist,ng)
       integer,pointer,dimension(:) :: alloc_groups
       integer,pointer,dimension(:) :: glist
       integer,intent(out) :: ng
     end function alloc_groups
  end interface

  integer,intent(in) :: lunit
  
  integer :: i,j,k,n,foo

  if (n_obj_type.eq.0) call abnormal_stop("init_object_type",&
       "The labels for objects could not find.")

  do i=1,n_obj_type

     ! Set the configuration
     obj_type(i)%config=>str2config(obj_type(i)%name)

     ! Determine total size
     n=0
     do j=1,n_point_type
        n=n+obj_type(i)%config(j)
     end do
     obj_type(i)%total_size=n

     ! Determine which group dose it belong?
     obj_type(i)%n_group_belong=0
     obj_type(i)%group_list=>&
          alloc_groups(obj_type(i)%config,n)
     obj_type(i)%n_group_belong=n

     ! determine the types of motions
     ! default mode
     obj_type(i)%motion_type=default_motion
     ! determine the specific motion
     do j=1,n_motion
        foo=0
        do k=1,obj_type(i)%n_group_belong
           if (mtype(j)%group_no.eq.obj_type(i)%group_list(k)) then
              foo=1
              exit
           end if
        end do
        if (foo.eq.1) &
             obj_type(i)%motion_type=mtype(j)%motion_type
     end do

     ! Assign default values for diffusion data
     obj_type(i)%does_move=.false.
     obj_type(i)%diff_eb=0
     obj_type(i)%diff_nu=0
     obj_type(i)%diff_const_rate=0

     ! Assign default values for dissociation data
     obj_type(i)%does_diss=.false.
     obj_type(i)%diss_type=0
     nullify(obj_type(i)%diss_eb)
     nullify(obj_type(i)%diss_nu)
     nullify(obj_type(i)%diss_rd)
     nullify(obj_type(i)%diss_const_rate)
     nullify(obj_type(i)%n_diss)
     nullify(obj_type(i)%diss_obj)

     ! Initialize react_group_list
     obj_type(i)%n_diss_react_group=0
     nullify(obj_type(i)%diss_react_group)

     ! Initialize the escape number thru free surface
     obj_type(i)%n_free_react_group=0
     nullify(obj_type(i)%free_react_group)

  enddo

  return

end subroutine init_object_type
